import Vue from 'vue'
const reg = /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g
let schoolId = ''
/**
 * 获取schoolId，当域名对应多个学校时，使用泛域名，第一个点号(.)前的是schooolId
 */
export default (callback: any) => {
  let locationString = window.location.href
  if (
    !Vue.prototype.$cookies.get('SAAS_S_ID') && 
    locationString.indexOf('xchsedu.com') > -1 && 
    locationString.split(".").length >= 4
  ) {
    schoolId = locationString.split(".")[0]
    Vue.prototype.$cookies.set('SAAS_S_ID', schoolId)
    callback(schoolId)
  } else {
    callback("")
  }
}